package com.example.elasticsearchdemo.module.user.service.impl;

import com.example.elasticsearchdemo.module.user.dao.UserRepository;
import com.example.elasticsearchdemo.module.user.entity.User;
import com.example.elasticsearchdemo.module.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author wangjianhua
 * @Description
 * @date 2021/7/7/007 17:13
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public List<User> findByNameOrPhone(String name, String phone) {
        return userRepository.findByNameOrPhone(name, phone);
    }

    @Override
    public List<User> findByNameAndPhone(String name, String phone) {
        return userRepository.findByNameAndPhone(name, phone);
    }

    @Override
    public User save(User user) {
        return userRepository.save(user);
    }

    @Override
    public Iterable<User> saveAll(List<User> userList) {
        return userRepository.saveAll(userList);
    }

    @Override
    public Optional<User> findById(String id) {
        return userRepository.findById(id);
    }

    @Override
    public boolean existsById(String id) {
        return userRepository.existsById(id);
    }

    @Override
    public Iterable<User> findAll() {
        return userRepository.findAll();
    }

    @Override
    public Iterable<User> findAllById(List<String> ids) {
        return userRepository.findAllById(ids);
    }

    @Override
    public long count() {
        return userRepository.count();
    }

    @Override
    public void deleteById(String id) {
        userRepository.deleteById(id);
    }

    @Override
    public void delete(User user) {
        userRepository.delete(user);
    }

    @Override
    public void deleteAll(List<User> userList) {
        userRepository.deleteAll(userList);
    }

    @Override
    public void deleteAll() {
        userRepository.deleteAll();
    }
}
